Vue.component("popup",{
    props:['type','content','callback'],
    template:'<div  @click="stop($event)" class="popup">'+
                '<div class="title">提示框<i @click="cancel" class="remove icon"></i></div>'+
                '<div class="content">{{content}}</div>'+
                '<div class="btn">' +
                    '<span @click="sure">确认</span>' +
                    '<span @click="cancel">取消</span>' +
                '</div>'+
            '</div>',
    methods: {
        sure: function() {
            this.$root.modal = false;
            if(typeof this.callback == "function") {
                this.callback();
            }
            this.$root.callback = {};
            this.$root.type = "default";
        },
        cancel: function () {
            this.$root.modal = false;
            if(this.type == "alert") {
                this.callback();
                if(typeof this.callback == "function") {
                    this.callback();
                }
                this.$root.callback = {};
            }
            this.$root.type = "default";
        },
        stop: function(event) {
            event.stopPropagation();
        },
    }
});

